package org.net.cms.controller.admin.application;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.net.cms.config.Result;
import org.net.cms.service.application.ApplicationService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/application")
@Tag(name = "管理后台 - 账号申请")
public class ApplicationController {

    @Resource
    private ApplicationService applicationService;

    @GetMapping("/list")
    @Operation(summary = "获取审核列表")
    @PermitAll
    @Parameter(name = "类型", description = "1获取已通过审核列表，2获取待审核了列表,0获取不通过审核列表", required = true)
    public Result admissionList(int type) {
        return Result.success(applicationService.applicationList(type));
    }

    @GetMapping("/get")
    @Operation(summary = "获取申请详情")
    @Parameter(name = "id", description = "申请id", required = true)
    public Result getAdmission(int id) {
        return Result.success(applicationService.getApplication(id));
    }

    @PostMapping("/update")
    @Operation(summary = "修改审核状态")
    @PermitAll
    public Result updateStatus(int id, int status) {
        applicationService.checkApplication(id, status);
        return Result.success();
    }

    @PostMapping("/delete")
    @Operation(summary = "删除申请信息")
    @Parameter(name = "id", description = "申请id", required = true)
    public Result deleteApplication(int id) {
        applicationService.deleteApplication(id);
        return Result.success();
    }

    @GetMapping("/unbind/list")
    @Operation(summary = "查看解绑审核列表")
    @Parameter(name = "type", description = "4解绑待审核，5解绑通过，6解绑不通过", required = true)
    public Result unbindStudentApplication(int type) {
        return Result.success(applicationService.getUnbindList(type));
    }

    @GetMapping("/unbind/get")
    @Operation(summary = "获取解绑详情")
    @Parameter(name = "id", description = "解绑id", required = true)
    public Result getUnbindApplication(int id) {
        return Result.success(applicationService.getApplication(id));
    }

    @PostMapping("/unbind/update")
    @Operation(summary = "修改解绑审核状态")
    public Result updateUnbindStatus(@RequestParam int id, @RequestParam int status) {
        applicationService.updateUnbindStatus(id, status);
        return Result.success();
    }
}
